51f9bb
@@ -110,6 +110,10 @@
static void populateSubstrOffsets(byte[] utf8String, int start, int len, int sub
       substrStart = length + substrStart;
     }
 
+    if (substrLength == 0) {
+      return;
+    }
+
     int endIdx = substrStart + substrLength - 1;
     for (int i = start; i != end; ++i) {
       if ((utf8String[i] & 0xc0) != 0x80) {
